#include<iostream>
#include<fstream>
using namespace std;
int buff[20] = { 0 };
int buff_[20] = { 0 };
ifstream infile;
bool huiwen(int x)
{
	int temp = x, y = 0;
	while (temp)
	{
		y = y * 10 + temp % 10;
		temp /= 10;
	}
	return (x == y);
}
int main()
{
	infile.open("out1.dat", ios::in | ios::binary);
	infile.getline((char*)buff, 100);
	int count = 0;
	for (int i = 0; i < 20; i++)
	{
		if (huiwen(buff[i]))
		{
			buff_[count] = buff[i];
			count++;
		}

	}

	int temp;
	for (int i = 0; i < count - 1; i++)
	{
		for (int j = 0; j < count - i - 1; j++)
		{
			if (buff_[j] > buff_[j + 1])
			{
				temp = buff_[j + 1];
				buff_[j + 1] = buff_[j];
				buff_[j] = temp;
			}
		}
	}
	for (int i = 0; i < count; i++)
	{
		cout << buff_[i] << " ";
	}
	return 0;

}